﻿@model projectManagementWeb.Models.Manager.modifyProjectModel

@{
    ViewBag.Title = "modifyProject";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div align="right">
    @Html.ActionLink("<< Regresar", "Index")
</div>

<style type="text/css">
.ui-datepicker { width: 17em; padding: .2em .2em 0; background: #66FF99;}
</style>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

<script src="@Url.Content("~/Scripts/jquery-ui-1.8.11.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $(".date").datepicker
            ({
                dateFormat: 'mm/dd/yy',
                showStatus: true,
                showWeeks: true,
                highlightWeek: true,
                numberOfMonths: 1,
                showAnim: "scale",
                showOptions: {
                    origin: ["top", "left"]
                }
            });
    });
</script>

<script type="text/javascript">
    function updateData() {
        $("#Name").val("");
        $("#Description").val("");
        $("#startDate").val("");
        $("#endDate").val("");
        var id = $("#ddlID").val();
        $.getJSON("/Manager/loadProjectInfo", { id: id },
					function (data) {
					    $("#Name").val(data.name);
					    $("#Description").val(data.description);
					    $("#startDate").val(data.startDate);
					    $("#endDate").val(data.endDate);
					    $("#projectLeaderID").val(data.projectLeaderID).attr('selected', true);
					    $("#sponsorID").val(data.sponsorID).attr('selected', true);
					    $("#statusID").val(data.statusID).attr('selected', true);
					    //$("#projectLeaderID").val(data.projectLeaderID);
					    //$("#sponsorID").val(data.sponsorID);
					    //$("#statusID").val(data.statusID);



					}
				);
    }

    $(document).ready(
	    function () {
	        updateData();
	        $("#ddlID").change(function () { updateData(); });
	    }
    );

</script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Modificar Proyecto</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.ID)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.ID, new SelectList(Model.ProjectList, "Value", "Text"), null, new { id = "ddlID" }) 
            @Html.ValidationMessageFor(model => model.ID)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Name, new { id = "Name" })
            @Html.ValidationMessageFor(model => model.Name)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Description)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Description, new { id = "Description" })
            @Html.ValidationMessageFor(model => model.Description)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.startDate)
        </div>
        <div class="editor-field">
             @if (Model == null)
             {
                @Html.TextBox("startDate", (DateTime.Now.ToString()), new { @class = "date",id = "startDate" })
             }
             else
             {
                @Html.TextBox("startDate", Model.startDate.ToString(), new { @class = "date",id = "startDate" })
             }
            @Html.ValidationMessageFor(model => model.startDate)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.endDate)
        </div>
        <div class="editor-field">
           @if (Model == null)
           {
                @Html.TextBox("endDate", (DateTime.Now.ToString()), new { @class = "date", id = "endDate" })
           }
           else
           {
                @Html.TextBox("endDate", Model.startDate.ToString(), new { @class = "date", id = "endDate" })
           }
            @Html.ValidationMessageFor(model => model.endDate)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.projectLeaderID)
        </div>
        <div class="editor-field">

           @Html.DropDownListFor(model => model.projectLeaderID, new SelectList(Model.ProjectLeaderIDList, "Value", "Text", Model.projectLeaderID),
          null, new { id = "projectLeaderID" }) 
            @Html.ValidationMessageFor(model => model.projectLeaderID)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.sponsorID)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.sponsorID, new SelectList(Model.SponsorIDList, "Value", "Text",Model.sponsorID),
       null, new { id = "sponsorID" }) 
            @Html.ValidationMessageFor(model => model.sponsorID)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.statusID)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.statusID, new SelectList(Model.StatusIDList, "Value", "Text", Model.sponsorID),
    null, new { id = "statusID" }) 
            @Html.ValidationMessageFor(model => model.statusID)
        </div>
        <p>
            <input type="submit" value="Guardar" />
        </p>
    </fieldset>
}


